import React, {Component} from 'react'

import {Image, View, Text, FlatList, TouchableOpacity, StyleSheet, Dimensions} from 'react-native'

const {width} = Dimensions.get('window')

import {setSpText, scaleSize} from "../utils/SreenUtil";

export default class TwoRowList extends Component {


  constructor(props){
    super(props)
  }

  todetail=()=>{
    //this.props.navigation.push('GoodsDetails')
    //alert(this.props.fun);
    //this.props.navigation.push('GoodsDetails');
    this.props.fun(this.props.item);
  }

  render() {

    let {item} = this.props;
    return (
        <TouchableOpacity onPress={this.todetail} activeOpacity={0.8}>
          <View style={styles.itemList}>
            <Image style={styles.productimg} source={{uri: item.pic2}}/>
            <Text style={styles.title_text} numberOfLines={2}>{item.title}</Text>
            <View style={styles.item_price_box}>
              <View style={styles.price_left}>
                <Text style={styles.text_left} style={styles.red}>￥{item.price}</Text>
              </View>
              <View style={styles.price_right}>
                  <Text style={styles.text_right}>￥{item.storePrice}</Text>
              </View>
            </View>
          </View>
        </TouchableOpacity>
    )
  }
}

const styles = StyleSheet.create({
  red:{
    fontSize:setSpText(30),
    color:'#ff1822'
  },
  itemList: {
    fontSize: 14,
    color: '#333',
    width: scaleSize(360),
    paddingBottom: scaleSize(27),
    backgroundColor: '#fff',
    marginBottom: scaleSize(10),
  },
  list_img_box: {},
  productimg: {
    width: scaleSize(360),
    height: scaleSize(360)
  },

  title_text:{
    paddingLeft:scaleSize(20),
    paddingRight:scaleSize(20),
    marginTop:scaleSize(23),
    marginBottom:scaleSize(26),
    color:'#454545'
  },

  item_price_box:{
    flexDirection:'row',
    alignItems:'center',
    paddingLeft:10,
    paddingRight:10
  },
  price_left:{
    flex:1,
    flexDirection:'row',
    alignItems:'center'
  },
  price_right:{
    flex:1,
    flexDirection:'row',
    alignItems:'center',
    justifyContent: 'flex-end'
  },
  text_left:{
    fontSize:setSpText(30)
  },
  text_right:{
    //textDecoration: 'line-through'
    textDecorationLine:'line-through'
  }

});